package com.oopnet.template.controller;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class CookieTestController {
	private static Logger log = Logger.getLogger(CookieTestController.class);
	@RequestMapping(value="/in")
	public String index(HttpServletRequest request,HttpServletResponse response,Exception e){
		log.error(e.getMessage());
		System.out.println("Hello Index...");
		Cookie[] cookies = request.getCookies();
		for (Cookie cookie : cookies) {
			System.out.println(cookie.getName()+": "+cookie.getValue());
		}
		
		Cookie selfCookie = new Cookie("LastAccessTime", System.currentTimeMillis()+"");
		response.addCookie(selfCookie);
		return "index";
	}
}
